﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;

namespace XiaoweiUWP.Models
{
    public class EventManager
    {

        private static Dictionary<String, Action<UserControl>> EventMap = new Dictionary<string, Action<UserControl>>();

        public static void Register(string key, Action<UserControl> act)
        {
            if(EventMap.ContainsKey(key))
            {
                EventMap[key] += act;
            }
            else
            {
                EventMap[key] = act;
            }
            
        }

        public static void Trigger(string key, UserControl arg)
        {
            if(EventMap.ContainsKey(key))
            {
                EventMap[key]?.Invoke(arg);
            }
        }





    }
}
